FROM golang:1.15.15 as builder
COPY . /app
WORKDIR /app
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOPROXY=https://goproxy.cn,direct
ENV GO111MODULE=on
RUN ls -l
RUN go build -a -installsuffix cgo -o ./go_log_server .

# 使用scratch开启
FROM alpine:latest

RUN mkdir -p /app

# 配置工作目录
WORKDIR /app/

# 拷贝配置文件
COPY ./config/application.yml /app/config/application.yml

# 拷贝编译程序
COPY --from=builder /app/go_log_server /app/

RUN chmod +x /app/go_log_server

# 运行!
CMD ["/app/go_log_server"]

# 打开8080端口
EXPOSE 8080